/**
 * 
 */
package com.freecsim.markdown.sql;

import org.apache.commons.lang3.StringUtils;

import com.freecsim.markdown.IMarkdownModel;

/**
 * @author Administrator
 *
 */
public class DocColumn implements IMarkdownModel{
	
	private String name;
	
	private String dataType;
	
	private boolean notNull;
	
	private boolean isPrimaryKey;
	
	private boolean unique;
	
	private boolean autoIncrement;
	
	private String comment;
	
	private String defaultValue;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public boolean isNotNull() {
		return notNull;
	}

	public void setNotNull(boolean notNull) {
		this.notNull = notNull;
	}

	public boolean isPrimaryKey() {
		return isPrimaryKey;
	}

	public void setPrimaryKey(boolean isPrimaryKey) {
		this.isPrimaryKey = isPrimaryKey;
	}

	public boolean isUnique() {
		return unique;
	}

	public void setUnique(boolean unique) {
		this.unique = unique;
	}

	public boolean isAutoIncrement() {
		return autoIncrement;
	}

	public void setAutoIncrement(boolean autoIncrement) {
		this.autoIncrement = autoIncrement;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String toMarkdownString() {
		StringBuilder sb = new StringBuilder();
		sb.append("|")
		  .append(StringUtils.defaultString(getName())).append("|")
		  .append(StringUtils.defaultString((getDataType()).toUpperCase())).append("|")
		  .append(isNotNull() ? "Y" : "N").append("|")
		  .append(StringUtils.defaultString(getDefaultValue())).append("|")
		  .append(StringUtils.defaultString(getComment())).append("|\n");
		return sb.toString();
	}
}
